home *** CD-ROM | disk | FTP | other *** search
/ PC-X 1997 October / pcx14_9710.iso / swag / delphi.swg / 0192_New Styles in COMCTL32.DLL.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1996-11-29  |  4.2 KB  |  103 lines

  1. (*============================================================================*
  2.  | The Internet Explorer release of COMCTL32.DLL introduced a number of new   |
  3.  | styles.  These aren't documented anywhere yet by Microsoft, although they  |
  4.  | do appear in the latest COMMCTRL.H supplied with VC4.2.  The styles mostly |
  5.  | only work when the ViewStyle property is set to vsReport.                  |
  6.  |                                                                            |
  7.  | The new styles are:                                                        |
  8.  |   GridLines        Displays thin, gray, horizontal and vertical lines      |
  9.  |                    separating rows and columns.                            |
  10.  |                                                                            |
  11.  |   SubItemImages    Displays images against sub-items as well as items.     |
  12.  |                                                                            |
  13.  |   CheckBoxes       Displays a check box at the start of each row.          |
  14.  |                                                                            |
  15.  |   TrackSelect      Colours the item as you drag the mouse over it.         |
  16.  |                    Automatically selects the item if you leave the mouse   |
  17.  |                    on it.                                                  |
  18.  |                                                                            |
  19.  |   HeaderDragDrop   Enables drag/drop from the report header.               |
  20.  |                                                                            |
  21.  |   FullRowSelect    Highlights the entire row when you select it instead of |
  22.  |                    just the first column data.                             |
  23.  |                                                                            |
  24.  |   OneClickActivate ??                                                      |
  25.  |   TwoClickActivate ??                                                      |
  26.  |                                                                            |
  27.  | Note that this component doesn't do anything except set the appropriate    |
  28.  | styles - so some styles may not be particularly useful.                    |
  29.  |                                                                            |
  30.  | Colin Wilson.  colin@wilsonc.demon.co.uk, or 100114.3641@compuserve.com    |
  31.  *============================================================================*)
  32.  
  33. unit cmpExtendedListView;
  34.  
  35. interface
  36.  
  37. uses
  38.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  39.   ComCtrls;
  40.  
  41. const
  42.   LVM_FIRST = $1000;
  43.   LVM_SETEXTENDEDLISTVIEWSTYLE = LVM_FIRST + 54;
  44.  
  45. type
  46.   TExtendedStyles = (lvexGridLines, lvexSubItemImages, lvexCheckBoxes, lvexTrackSelect,
  47.                      lvexHeaderDragDrop, lvexFullRowSelect, lvexOneClickActivate, lvexTwoClickActivate);
  48.   TExtendedStyleRange = lvexGridLines..lvexTwoClickActivate;
  49.   TExtendedStyleSet = set of TExtendedStyleRange;
  50.  
  51. const
  52.   LVS_EX_Styles : array [TExtendedStyleRange] of Integer = (
  53.     $00000001, $00000002, $00000004, $00000008,
  54.     $00000010, $00000020, $00000040, $00000080);
  55.  
  56. type
  57.   TExtendedListView = class(TListView)
  58.   private
  59.     fExtendedStyle : TExtendedStyleSet;
  60.     procedure SetExtendedStyle (value : TExtendedStyleSet);
  61.  
  62.   protected
  63.     procedure CreateWnd; override;
  64.  
  65.   published
  66.     property ExtendedStyle : TExtendedStyleSet read fExtendedStyle write SetExtendedStyle;
  67.   end;
  68.  
  69. procedure Register;
  70.  
  71. implementation
  72.  
  73. procedure TExtendedListView.SetExtendedStyle (value : TExtendedStyleSet);
  74. var
  75.   exStyle : Integer;
  76.   i : TExtendedStyleRange;
  77. begin
  78.   if HandleAllocated then
  79.   begin
  80.     exStyle := 0;
  81.     for i := Low (TExtendedStyleRange) to High (TExtendedStyleRange) do
  82.       if i in value then exStyle := exStyle or LVS_EX_STYLES [i];
  83.  
  84.     SendMessage(Handle, LVM_SETEXTENDEDLISTVIEWSTYLE, 0, exStyle)
  85.   end;
  86.   fExtendedStyle := value;
  87.   Refresh
  88. end;
  89.  
  90. procedure TExtendedListView.CreateWnd;
  91.  
  92. begin
  93.   inherited CreateWnd;
  94.   SetExtendedStyle (fExtendedStyle);
  95. end;
  96.  
  97. procedure Register;
  98. begin
  99.   RegisterComponents('Samples', [TExtendedListView]);
  100. end;
  101.  
  102. end.
  103.